package com.zizhu.idgen.repository.impl;



import com.zizhu.common.ddd.domain.support.jpa.JpaRepositorySupport;
import com.zizhu.idgen.domain.NumberConfig;
import com.zizhu.idgen.domain.NumberConfigStatus;
import com.zizhu.idgen.repository.NumberConfigRepository;
import com.zizhu.idgen.repository.impl.dao.VirtualNumberDao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Optional;


/**
 * Created by Administrator on 2018/1/24 0024.
 */
@Repository
public class NumberConfigRepositoryImpl extends JpaRepositorySupport<NumberConfig> implements NumberConfigRepository {

    @Resource
    private VirtualNumberDao virtualNumberDao;

    public NumberConfigRepositoryImpl(JpaRepository<NumberConfig, Long> repository) {
        super(repository);
    }


    @Override
    public Optional<NumberConfig> getFirstByStatus(NumberConfigStatus status) {
        return this.virtualNumberDao.getFirstByStatusOrderByIdAsc(status);
    }
}